package org.lhy.hubuoj.judge;

import org.lhy.hubuoj.judge.strategy.DefaultJudgeStrategyImpl;
import org.lhy.hubuoj.judge.strategy.JavaJudgeStrategyImpl;
import org.lhy.hubuoj.judge.strategy.JudgeContext;
import org.lhy.hubuoj.judge.strategy.JudgeStrategy;
import org.lhy.hubuoj.judge.model.JudgeInfo;
import org.springframework.stereotype.Component;

/**
 * 判题管理（简化调用）
 *
 * @author 没天赋
 * @since 2025-04-08
 */
@Component
public class JudgeManager {

    /**
     * 执行判题，根据语言选择不同的策略工厂
     * @param judgeContext
     * @return
     */
    public JudgeInfo doJudge(JudgeContext judgeContext) {
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategyImpl();
        String language = judgeContext.getQuestionSubmit().getLanguage();
        if (language.equals("Java")) {
            judgeStrategy = new JavaJudgeStrategyImpl();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
